﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace MagicFight
{
    public class Rejuvenation : Magic
    {
        int HPgain = Def.RejuvenationDef.HPGain;
        double Duration = Def.RejuvenationDef.Duration;
        int Interval = Def.RejuvenationDef.Interval;
        double tick = 0;

        public Rejuvenation(Character caster)
            : base(caster, Def.RejuvenationDef.N) { }

        public override void Effect(GameTime gameTime)
        {
            tick += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (tick > Interval)
            {
                tick -= Interval; 
                int a = caster.GainHP(HPgain);
                if (a >= 0) ps.effectsManager.Add(new FloatingText(caster.position, a.ToString(), Color.Green));
            }

            Duration -= gameTime.ElapsedGameTime.TotalMilliseconds;
            if (Duration < 0) 
                alive = false;
        }
    }
}
